package com.block.common.util;

import cn.hutool.core.util.StrUtil;

public class ChainTokenUtil {

    private static final String token_url = "https://nemotest-1309878059.cos.ap-singapore.myqcloud.com/coinimg/128/%s.png";
    private static final String chain_url = "https://nemotest-1309878059.cos.ap-singapore.myqcloud.com/chainimg/%s.png";

    public static String getTokenLogo(String tokenName) {
        return String.format(token_url, tokenName.toLowerCase());
    }

    public static String getChainLogo(String chainType) {
        return String.format(chain_url, chainType.toLowerCase());
    }


    /**
     * 根据vmType判断合约地址是否合法
     * @param keyWord
     * @param vmType
     * @return
     */
    public static boolean isContractAddress(String keyWord, String vmType) {
        if (VM_TYPE_EVM.equals(vmType)) {
            return StrUtil.length(keyWord) == 42 && keyWord.startsWith("0x");
        }
        return false;
    }

    static final String VM_TYPE_EVM = "EVM";

}
